<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../../inc/conn.asp"-->
<!--#include file="../user/common/u.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>购物车</title>
<meta name="keywords" content="购物车" />
<meta name="description" content="购物车" />
<link href="favicon.ico" rel="shortcut icon" type="image/x-icon"/>
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
	$('#select_1').change(function(){ 
		$('#search_1').val($(this).find("option:selected").text());
	});
}); 
$(function (){
  $(".main_class_li").hover(function(){
	$(".child_class",this).show();
  });
  $(".main_class_li").mouseleave(function(){
	$(".child_class",this).hide();
  });
});
</script>
<script type="text/javascript">
function changeNum(obj,num){    
var input = getParent(obj).getElementsByTagName("input");    
for(var i=0;i<input.length;i++)    {        
if(input[i].type=="text")        {            
if(input[i].value == "")                
input[i].value = num;            
else          
input[i].value = input[i].value - 0 + num;   
if (input[i].value<1){
input[i].value=1
}
}    } }
//获取父级对像
function getParent(obj){    if(typeof(obj) != "object"){obj = document.getElementById(obj);}    if(obj)        return obj.parentElement || obj.parentNode;}
</script>
</head>
<body onload="add()">



<!--#include file="../common/topshopping.asp"-->




<div class="fullwidth bg2">
	<div class="place ">
		<a href="/">首页</a> &gt; <a href="/shopping">我要代购</a> &gt; 购物车
	</div>
</div>

<!--main-->
<div class="fullwidth bg1">
	<div class="main">
    <%if CartNull="0" then%>
    <div style="text-align:center">购物车没有商品！<a href="/shopping">去购物</a></div>
    <%else%>
    <form  class="registerform" action="" name="formreg" method="post">
		<div class="clear20"></div>
		<table class="stable">
			<tr class="str">
				<th class="th_1">商品名</th>
				<th>单价</th>
				<th>数量</th>
				<th>日本国内运费</th>
				<th class="th_5">备注</th>
				<th>总价格</th>				
				<th>操作</th>				
			</tr>
            
            
            
            <%
					set rslist=server.CreateObject("adodb.recordset")
					sql="select * from cart where uid='"&request.Cookies("u")("uid")&"'"
					rslist.open sql,conn,1,3
					if not rslist.eof then
					c=1
					do while not rslist.eof
					   set rsSource=conn.execute("select * from Source where id="&rslist("sid")&"") '来源
					   set rsShop=conn.execute("select * from Shop where sid="&rsSource("sid")&"") '店铺
					   set rsproduct=conn.execute("select * from product where pid="&rsSource("pid")&"") '产品
					%>
			<tr>
				<td>
					<dl>
						<dt><a href="/shopping/<%=rsproduct("pid")%>.html"><img src="<%=rsproduct("pic")%>" width="99" height="100" alt=""></a></dt>
						<dd><a href="/shopping/<%=rsproduct("pid")%>.html"><%=rsproduct("title")%></a></dd>
						<dd class="shop_n"><a><%if rsShop("typeid")="0" then response.Write "实体店" else response.Write "购物网"%>-<%=rsShop("address")%>-<%=rsShop("title")%></a></dd>
					</dl>
				</td>
				<td><n id="price<%=c%>"><%=rsSource("price")%></n>日元</td>
				<td>
					<!--<span class="s_add" onClick="changeNum(this,-1)">-</span>--><input id="qty<%=c%>" onpropertychange="add()" oninput="add()" name="qty<%=rslist("id")%>" type="text" value="<%=rslist("qty")%>" class="s_c_value" datatype="n1-4" ajaxurl="/cart/qty" nullmsg="请输入购买数量！" errormsg="输入错误" style="width:60px" /><!--<span class="s_add"  onClick="changeNum(this,1)" onpropertychange="add()" oninput="add()">+</span>-->
				</td>
				<td><n id="transCost<%=c%>"><%=rsSource("transCost")%></n>日元
                <%transCost=transCost+cdbl(rsSource("transCost"))%>
                </td>
				<td><textarea name="content<%=rslist("id")%>" datatype="*" ignore="ignore" ajaxurl="/cart/qty" nullmsg="内容" errormsg="内容" ><%=rslist("content")%></textarea></td>
				<td><n id="Subtotal<%=c%>"><%=(cdbl(rslist("qty"))*cdbl(rsSource("price")))+cdbl(rsSource("transCost"))%></n>日元
                
                <%tomoney=tomoney+(cdbl(rslist("qty"))*cdbl(rsSource("price")))%>
                </td>
				<td><a href="?del=<%=rslist("id")%>" class="del">删除</a><input type="hidden" name="cid" value="<%=rslist("id")%>" /></td>
			</tr>
            <%
					c=c+1
					   set rsproduct=nothing
					   set rsShop=nothing
					   set rsSource=nothing
					rslist.movenext
					loop
					rslist.close
					set rslist=nothing
					end if		 
					%> 
            
            
            
            
            
            
            
			
		</table>
		<div class="clear20"></div>
		<div class="width900">
			<div class="cart_box_1 f_l">
				<table class="stable stable_1 cart_table_1">
					<tr>
						<th width="50%">商品总费用</th>
						<th width="50%">代购服务费</th>
					</tr>
					<%
					  set rsu=server.CreateObject("adodb.recordset")
					  sql="select * from ServiceCost where usertype="&GradeID&""
					  rsu.open sql,conn,1,3
					  if not rsu.eof then
					  do while not rsu.eof
					  %>
                    <tr>
						<td><%=rsu("StartMoney")&"~"&rsu("EndMoney")%>日元</td>
						<td><%=rsu("rate")%>%</td>
					</tr>
                    <%
					
					'计算服务费
					if cdbl(tomoney)>cdbl(rsu("StartMoney")) and cdbl(tomoney)<=cdbl(rsu("EndMoney")) then servicemoneyrate=rsu("rate")
					
					  rsu.movenext
					  loop
					  rsu.close
					  set rsu=nothing
					  end if		 
					  %>
					
				</table>
			</div>
			<div class="cart_box_2 f_r">
				<table class="stable stable_1">
					<tr>
						<td class="select_td_1 select_td_norborder">费用一览</td>
						<td class="gray select_td_nolborder" ></td>
					</tr>
					<tr>
						<td class="select_td_1">商品总费用</td>
						<td style="text-indent:0px; text-align:center"><n id="TotalProduct"><%=formatNumber((cdbl(tomoney)+cdbl(transCost))*cdbl(web_rate),0)%></n>RMB (<n id="TotalProductjp"><%=formatNumber(cdbl(tomoney)+cdbl(transCost),0)%></n>日元)</td>
					</tr>
					<tr>
						<td class="select_td_1">代购服务费</td>
						<td style="text-indent:0px; text-align:center"><n id="servicecost"><%=formatNumber(((cdbl(tomoney)+cdbl(transCost))*(cdbl(servicemoneyrate)/100))*cdbl(web_rate),0)%></n>RMB (<n id="servicecostjp"><%=formatNumber((cdbl(tomoney)+cdbl(transCost))*(cdbl(servicemoneyrate)/100),0)%></n>日元)</td>
					</tr>
					<tr>
						<td class="select_td_1">总费用</td>
						<td style="text-indent:0px; text-align:center"><font class="red"><n id="TotalMoney"><%=formatNumber((cdbl(tomoney)+cdbl(transCost)+((cdbl(tomoney)+cdbl(transCost))*(cdbl(servicemoneyrate)/100)))*cdbl(web_rate),0)%></n>RMB (<n id="TotalMoneyjp"><%=formatNumber(cdbl(tomoney)+cdbl(transCost)+((cdbl(tomoney)+cdbl(transCost))*(cdbl(servicemoneyrate)/100)),0)%></n>日元)</font></td>
					</tr>
				</table>
			</div>
			<div class="clear20"></div>
			<div class="btn text_right">
				<!--<a href="javascript:void(0);" onclick="formreg.submit()" class="btn_13">保存购物车</a>-->
				<a href="#" class="btn_14 btn_sub">下一步</a>
				<input type="hidden" name="t" value="y" />
            </div>
		</div>
		</form>
        <%end if%>
	</div>
</div>

<div class="clear"></div>



<!--#include file="../common/footerauctions.asp"-->



<%
'删除产品
if request.QueryString("del")<>"" then
conn.execute("delete from cart where uid='"&request.Cookies("u")("uid")&"' and id="&request.QueryString("del")&"")
response.Redirect "/cart"
end if


if request.Form("t")="y" then

if request.Form("cid")="" then
response.write"<script>alert('请先添加商品');</script>"
response.write"<script>window.history.back(-1);</script>"
response.end
end if

Proid=replace(request.Form("cid")," ","")
Proid=split(Proid,",")
for i=0 to ubound(Proid)
	  set rsx=server.createobject("adodb.recordset")
	  sql="select * from cart where uid='"&request.Cookies("u")("uid")&"' and id="&Proid(i)&""
	  rsx.open sql,conn,1,3
	  rsx("qty")=request.Form("qty"&Proid(i))
	  rsx("content")=request.Form("content"&Proid(i))
	  rsx.update
	  rsx.close
	  set rsx=nothing
next
response.Redirect "/cart/confirm"
end if
%>









<script >
function add(){
<%
c=c-1
for i=1 to c
%>
document.getElementById("Subtotal<%=i%>").innerHTML=(parseInt(document.getElementById("qty<%=i%>").value)*parseInt(document.getElementById("price<%=i%>").innerHTML))+parseInt(document.getElementById("transCost<%=i%>").innerHTML);
<%
'小计相加
if TotalProduct="" then TotalProduct="parseInt(document.getElementById(""Subtotal"&i&""").innerHTML)" else TotalProduct=TotalProduct+"+parseInt(document.getElementById(""Subtotal"&i&""").innerHTML)"
next
%>
//商品金额统计
document.getElementById("TotalProduct").innerHTML=(<%=TotalProduct%>)*<%=web_rate%>;
document.getElementById("TotalProductjp").innerHTML=<%=TotalProduct%>;
//服务费统计
<%
set rsu=server.CreateObject("adodb.recordset")
sql="select * from ServiceCost where usertype="&GradeID&""
rsu.open sql,conn,1,3
if not rsu.eof then
do while not rsu.eof
%>
if ((document.getElementById("TotalProduct").innerHTML><%=cdbl(rsu("StartMoney"))%>)&&(document.getElementById("TotalProduct").innerHTML<<%=cdbl(rsu("EndMoney"))%>)){
document.getElementById("servicecost").innerHTML=Math.ceil((parseInt(document.getElementById("TotalProduct").innerHTML)*<%=rsu("rate")/100%>)*<%=web_rate%>);
document.getElementById("servicecostjp").innerHTML=Math.ceil(parseInt(document.getElementById("TotalProduct").innerHTML)*<%=rsu("rate")/100%>);
}
<%
rsu.movenext
loop
rsu.close
set rsu=nothing
end if		 
%>
//总金额统计
document.getElementById("TotalMoney").innerHTML=(parseInt(document.getElementById("TotalProduct").innerHTML)+parseInt(document.getElementById("servicecost").innerHTML))*<%=web_rate%>;
document.getElementById("TotalMoneyjp").innerHTML=parseInt(document.getElementById("TotalProduct").innerHTML)+parseInt(document.getElementById("servicecost").innerHTML);
}
</script>





<link rel="stylesheet" href="/Validform/css/style.css" type="text/css" media="all" />
<script type="text/javascript" src="/Validform/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="/Validform/js/Validform_v5.3.2_min.js"></script>

<script type="text/javascript">
$(function(){
	//$(".registerform").Validform();  //就这一行代码！;
		
	$(".registerform").Validform({
		btnSubmit:".btn_sub", 
		//btnReset:".btn_reset",
		//tiptype:1, 
		tiptype:function(msg,o,cssctl){
			//msg：提示信息;
			//o:{obj:*,type:*,curform:*}, obj指向的是当前验证的表单元素（或表单对象），type指示提示的状态，值为1、2、3、4， 1：正在检测/提交数据，2：通过验证，3：验证失败，4：提示ignore状态, curform为当前form对象;
			//cssctl:内置的提示信息样式控制函数，该函数需传入两个参数：显示提示信息的对象 和 当前提示的状态（既形参o中的type）;
			if(!o.obj.is("form")){//验证表单元素时o.obj为该表单元素，全部验证通过提交表单时o.obj为该表单对象;
				var objtip=o.obj.siblings(".Validform_checktip");
				cssctl(objtip,o.type);
				objtip.text(msg);
			}
		}
	});
})
</script>



</body>
</html>